
#include <BVector>
#include "ClassVector.h"

ClassVector::ClassVector() : BClass("Vector", true)
{
	this->insertMethod("Vector()", &ClassVector::init);
	this->insertMethod("Vector(real,real,real)", &ClassVector::init_xyz);
	this->insertMethod("Vector(const Vector&)", &ClassVector::init_other);

	this->insertMethod("void reset()", &ClassVector::reset);
	this->insertMethod("void set(real,real,real)", &ClassVector::set);

	this->insertMethod("const real x() const", &ClassVector::x);
	this->insertMethod("const real y() const", &ClassVector::y);
	this->insertMethod("const real z() const", &ClassVector::z);

	this->insertMethod("void setX(const real&)", &ClassVector::setX);
	this->insertMethod("void setY(const real&)", &ClassVector::setY);
	this->insertMethod("void setZ(const real&)", &ClassVector::setZ);

	this->insertMethod("void normalize()", &ClassVector::normalize);
	this->insertMethod("Vector normal() const", &ClassVector::normal);

	this->insertMethod("void inverse()", &ClassVector::inverse);
	this->insertMethod("void reverse()", &ClassVector::reverse);

	this->insertMethod("void setLength(real)", &ClassVector::setLength);
	this->insertMethod("real length() const", &ClassVector::length);
	this->insertMethod("real length2() const", &ClassVector::length2);

	this->insertMethod("real dot(real,real,real) const", &ClassVector::dot_xyz);
	this->insertMethod("Vector dot(const Vector&) const", &ClassVector::dot_other);

	this->insertMethod("real angle(real,real, real) const", &ClassVector::angle_xyz);
	this->insertMethod("real angle(const Vector&) const", &ClassVector::angle_other);

	this->insertMethod("Vector cross(real,real,real) const", &ClassVector::cross_xyz);
	this->insertMethod("Vector cross(const Vector&) const", &ClassVector::cross_other);

	this->insertMethod("const Vector& =(const Vector&)", &ClassVector::assign);

	this->insertMethod("Vector +(real) const", &ClassVector::plus_value);
	this->insertMethod("Vector +(const Vector&) const", &ClassVector::plus_other);

	this->insertMethod("void +=(real)", &ClassVector::plus_equal_value);
	this->insertMethod("void +=(const Vector&)", &ClassVector::plus_equal_other);

	this->insertMethod("Vector -() const", &ClassVector::minus_self);
	this->insertMethod("Vector -(real) const", &ClassVector::minus_value);
	this->insertMethod("Vector -(const Vector&) const", &ClassVector::minus_other);

	this->insertMethod("void -=(real)", &ClassVector::minus_equal_value);
	this->insertMethod("void -=(const Vector&)", &ClassVector::minus_equal_other);

	this->insertMethod("Vector *(real) const", &ClassVector::mult_value);
	this->insertMethod("Vector *(const Vector&) const", &ClassVector::mult_other);

	this->insertMethod("void *=(real)", &ClassVector::mult_equal_value);
	this->insertMethod("void *=(const Vector&)", &ClassVector::mult_equal_other);

	this->insertMethod("Vector /(real) const", &ClassVector::div_value);
	this->insertMethod("Vector /(const Vector&) const", &ClassVector::div_other);

	this->insertMethod("/=(real)", &ClassVector::div_equal_value);
	this->insertMethod("/=(const Vector&)", &ClassVector::div_equal_other);

	this->insertMethod("bool ==(const Vector&) const", &ClassVector::equal);
	this->insertMethod("bool !=(const Vector&) const", &ClassVector::unequal);

	this->insertMethod("bool >(const Vector&)", &ClassVector::greater_other);
	this->insertMethod("bool >=(const Vector&)", &ClassVector::greater_equal_other);

	this->insertMethod("bool <(const Vector&)", &ClassVector::less_other);
	this->insertMethod("bool <=(const Vector&)", &ClassVector::less_equal_other);
}

void ClassVector::init(int argc, BValue* argv)
{
	BVector& vec = argv[0].fill<BVector>();
}
void ClassVector::init_xyz(int argc, BValue* argv)
{
	BVector& vec = argv[0].fill<BVector>();
	BReal x = argv[1];
	BReal y = argv[2];
	BReal z = argv[3];
	vec.set(x, y, z);
}
void ClassVector::init_other(int argc, BValue* argv)
{
	const BVector& other = argv[1];
	BVector& vec = argv[0].fill<BVector>();
	vec = other;
}

void ClassVector::reset(int argc, BValue* argv)
{
	BVector& v = argv[0];
	v.reset();
}
void ClassVector::set(int argc, BValue* argv)
{
	BVector& v = argv[0];
	BReal x = argv[1];
	BReal y = argv[2];
	BReal z = argv[3];
	v.set(x, y, z);
}

void ClassVector::x(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	argv[0] = v.x();
}
void ClassVector::y(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	argv[0] = v.y();
}
void ClassVector::z(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	argv[0] = v.z();
}

void ClassVector::setX(int argc, BValue* argv)
{
	BVector& v = argv[0];
	BReal x = argv[1];
	v.x() = x;
}
void ClassVector::setY(int argc, BValue* argv)
{
	BVector& v = argv[0];
	BReal y = argv[1];
	v.y() = y;
}
void ClassVector::setZ(int argc, BValue* argv)
{
	BVector& v = argv[0];
	BReal z = argv[1];
	v.z() = z;
}

void ClassVector::normalize(int argc, BValue* argv)
{
	BVector& v = argv[0];
	v.normalize();
}
void ClassVector::normal(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	argv[0] = v.normal();
}

void ClassVector::inverse(int argc, BValue* argv)
{
	BVector& v = argv[0];
	v = -v;
}
void ClassVector::reverse(int argc, BValue* argv)
{
	BVector& v = argv[0];
	bSwap(v.x(), v.z());
}

void ClassVector::setLength(int argc, BValue* argv)
{
	BVector& v = argv[0];
	BReal length = argv[1];
	v.setLength(length);
}
void ClassVector::length(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	argv[0] = v.length();
}
void ClassVector::length2(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	argv[0] = v.length2();
}

void ClassVector::dot_xyz(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	BReal x = argv[1];
	BReal y = argv[2];
	BReal z = argv[3];
	argv[0] = v.dot(x, y, z);
}
void ClassVector::dot_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = v.dot(v1);
}

void ClassVector::angle_xyz(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	BReal x = argv[1];
	BReal y = argv[2];
	BReal z = argv[3];
	argv[0] = v.angle(x, y, z);
}
void ClassVector::angle_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = v.angle(v1);
}

void ClassVector::cross_xyz(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	BReal x = argv[1];
	BReal y = argv[2];
	BReal z = argv[3];
	argv[0] = v.cross(x, y, z);
}
void ClassVector::cross_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = v.cross(v1);
}

void ClassVector::assign(int argc, BValue* argv)
{
	BVector& v = argv[0];
	const BVector& v1 = argv[1];
	v = v1;
	argv[0] = v;
}

void ClassVector::plus_value(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	BReal x = argv[1];
	argv[0] = v + x;
}
void ClassVector::plus_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = v + v1;
}

void ClassVector::plus_equal_value(int argc, BValue* argv)
{
	BVector& v = argv[0];
	BReal r = argv[1];
	v += r;
}
void ClassVector::plus_equal_other(int argc, BValue* argv)
{
	BVector& v = argv[0];
	const BVector& v1 = argv[1];
	v += v1;
}

void ClassVector::minus_self(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	argv[0] = -v;
}
void ClassVector::minus_value(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	BReal r = argv[1];
	argv[0] = v - r;
}
void ClassVector::minus_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = v - v1;
}

void ClassVector::minus_equal_value(int argc, BValue* argv)
{
	BVector& v = argv[0];
	BReal r = argv[1];
	v -= r;
}
void ClassVector::minus_equal_other(int argc, BValue* argv)
{
	BVector& v = argv[0];
	const BVector& v1 = argv[1];
	v -= v1;
}

void ClassVector::mult_value(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	BReal r = argv[1];
	argv[0] = v * r;
}
void ClassVector::mult_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = v * v1;
}

void ClassVector::mult_equal_value(int argc, BValue* argv)
{
	BVector& v = argv[0];
	BReal r = argv[1];
	v *= r;
}
void ClassVector::mult_equal_other(int argc, BValue* argv)
{
	BVector& v = argv[0];
	const BVector& v1 = argv[1];
	v *= v1;
}

void ClassVector::div_value(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	BReal r = argv[1];
	argv[0] = v / r;
}
void ClassVector::div_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = v / v1;
}

void ClassVector::div_equal_value(int argc, BValue* argv)
{
	BVector& v = argv[0];
	BReal r = argv[1];
	v /= r;
}
void ClassVector::div_equal_other(int argc, BValue* argv)
{
	BVector& v = argv[0];
	const BVector& v1 = argv[1];
	v /= v1;
}

void ClassVector::equal(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = (v == v1);
}
void ClassVector::unequal(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = (v != v1);
}

void ClassVector::greater_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = (v > v1);
}
void ClassVector::greater_equal_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = (v >= v1);
}

void ClassVector::less_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = (v < v1);
}
void ClassVector::less_equal_other(int argc, BValue* argv)
{
	const BVector& v = argv[0];
	const BVector& v1 = argv[1];
	argv[0] = (v <= v1);
}
